﻿using System;
using System.Web;
using System.Web.UI.WebControls;

using OctoOS;
using OctoOS.Resources;
using OctoOS.UI;

public partial class __editSection : OOSPage
{
	class PathInfo
	{
		[PathInfoMember(0)]
		[RangeValidator(1, Int64.MaxValue)]
		[IntegerBase(64)]
		internal long ArticleID = 0;

		[PathInfoMember(1)]
		[RangeValidator(1, Int64.MaxValue)]
		internal long PageID = 0;
	}

	PathInfo _pathInfo;

	protected void Page_Init(object sender, EventArgs e)
	{
		_pathInfo = EnablePathInfo<PathInfo>();
	}

    protected void Page_Load(object sender, EventArgs e)
    {
		var article = ApiService.GetArticle(OOSRequest.Current, _pathInfo.ArticleID);
		if(!OOSRequest.Current.IsModerator &&
				article.UserID != OOSRequest.Current.UserID)
		{
			throw new HttpException();
		}

		AddBreadcrumb("", "/");
		AddBreadcrumb(Resources.Main.shared_MyArticlesLink, Urls.GetMyArticles());
		AddBreadcrumb(Resources.Main.shared_EditArticleLink, Urls.GetEditArticle(_pathInfo.ArticleID));

		PageTitle = Resources.Main.editSection_AddTitle;

		myForm.Action = Urls.Ajax.GetSaveSection();
		pageID.Value = _pathInfo.PageID.ToString();
		articleID.Value = _pathInfo.ArticleID.ToString();

		save.Text = OOSResources.Button_Submit;
		cancel.Text = OOSResources.Button_Cancel;
    }
}